package com.shu.mqtt;

import org.fusesource.hawtbuf.Buffer;
import org.fusesource.hawtbuf.UTF8Buffer;
import org.fusesource.mqtt.client.Listener;

public class ConnListener implements Listener{

    public void onDisconnected() {
        System.out.println("listen disConnect");
    }

    public void onConnected() {
        System.out.println("listent connect");
    }

    public void onPublish(UTF8Buffer topic, Buffer payload, Runnable ack) {
        System.out.println("listen publish");
        System.out.println(UTF8Buffer.decode(topic));
        System.out.println(UTF8Buffer.decode(Buffer.utf8(payload)));
        ack.run();
    }

    public void onFailure(Throwable value) {
        System.out.println("listen fail" + value.toString());
    }

}
